using UnityEngine;

public class FollowZAxis : MonoBehaviour
{
    [Tooltip("要跟随 Z 轴的目标对象")]
    public Transform target;

    void Update()
    {
        if (target != null)
        {
            Vector3 position = transform.position;
            position.z = target.position.z;
            transform.position = position;
        }
    }
}
